﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class RoleDal
    {
        DBHepler hepler = new DBHepler();

        /// <summary>
        /// 得到所有的权限
        /// </summary>
        /// <returns></returns>
        public DataTable GetAllRole()
        {
            return hepler.GetDataTableByProc("sp_Role_GetAll");
        }

        /// <summary>
        /// 增加权限信息
        /// </summary>
        /// <param name="roleName"></param>
        /// <returns></returns>
        public bool AddRole(string roleName)
        {
            SqlParameter[] parameters = {
                                            new SqlParameter("@roleName",roleName)
                                        };
            if (hepler.UpdateByProc("sp_Role_Add", parameters) > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool DeleteRole(int roleId)
        {
            SqlParameter[] parameters = {
                                            new SqlParameter("@roleId",roleId)
                                        };
            if (hepler.UpdateByProc("sp_Role_Delete", parameters) > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        
    }
}
